#include<bits/stdc++.h>
using namespace std;
//~ #define int long long
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
int n,m,L,vm;
int d[maxn],v[maxn],a[maxn];
int pos[maxn];
vector<int>num;
struct node{
	int l,r;
	bool operator<(const node&x)const{
		if(r==x.r)return l<x.l;
		else return r<x.r;
	}
}A[maxn];
void solve(){
	n=read(),m=read(),L=read(),vm=read();
	for(int i=1;i<=n;i++)d[i]=read(),v[i]=read(),a[i]=read();
	for(int i=1;i<=m;i++)pos[i]=read();
	sort(pos+1,pos+m+1);
	pos[m+1]=L+1;
	int cnt1=0;
	num.clear();
	int ln=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0&&d[i]<=pos[m]&&v[i]>vm){
			int l=d[i],r=L;
			int p1=lower_bound(pos+1,pos+m+1,l)-pos;
			int p2=lower_bound(pos+1,pos+m+1,r)-pos;if(pos[p2]>r)p2--;
			if(l>pos[m]||r<pos[1])continue;
			if(p1<=p2)cnt1++,A[++ln]={p1,p2};
		}
		else if(a[i]>0){
			long double xr=1.0*abs(vm*vm-v[i]*v[i])/2/a[i];
			if(v[i]>vm)xr=0.0;
			int l=ceil(xr)+d[i],r=L;
			if(l>r)continue;
			int p1=lower_bound(pos+1,pos+m+1,l)-pos;
			int p2=lower_bound(pos+1,pos+m+1,r)-pos;if(pos[p2]>r)p2--;
			if(abs(vm*vm-v[i]*v[i])%(2*abs(a[i]))==0&&pos[p1]==l)p1++;
			if(l>pos[m]||r<pos[1])continue;
			if(p1<=p2)cnt1++,num.push_back(i),A[++ln]={p1,p2};
		}
		else if(a[i]<0){
			if(v[i]<=vm)goto end;
			long double xr=1.0*abs(vm*vm-v[i]*v[i])/2/abs(a[i]);
			int r=floor(xr)+d[i],l=d[i];
			int p1=lower_bound(pos+1,pos+m+1,l)-pos;
			int p2=lower_bound(pos+1,pos+m+1,r)-pos;if(pos[p2]>r)p2--;
			if((abs(vm*vm-v[i]*v[i]))%(2*abs(a[i]))==0&&pos[p2]==r)p2--;
			if(l>pos[m]||r<pos[1])continue;
			if(p1<=p2)cnt1++,num.push_back(i),A[++ln]={p1,p2};
		}
		end:;
	}
	sort(A+1,A+ln+1);
	int tl=A[1].l,tr=A[1].r,cnt2=0;
	for(int i=2;i<=ln;i++){
		int l=A[i].l,r=A[i].r;
		if(l>tr){
			cnt2++;
			tl=l,tr=r;
		}
		tl=max(tl,l);
		tr=min(tr,r);
	}
	if(tl<=tr&&ln>0)cnt2++;
	printf("%d %d\n",cnt1,m-cnt2);
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--){
		solve();
	}
	return 0;
}
